home *** CD-ROM | disk | FTP | other *** search
- /* %filename% */
- /* Created %date% %time% by AppMaker */
-
- #include <Types.h>
- #include <Quickdraw.h>
- #include <Controls.h>
- #include <Dialogs.h>
- #include <Events.h>
- #include <Lists.h>
- #include <Menus.h>
- #include <TextEdit.h>
- #include "Globals.h"
- #include "ResourceDefs.h"
- #include "Miscellany.h"
- %for each menu gen include%
-
- #include <Desk.h>
- #include <ToolUtils.h>
- #include "MainMenu.h"
-
- %If lang = MPW%
- #pragma segment MainMenu
-
- %end if%
-
- static void Enable (short itemNr,
- Boolean enabled);
- static void EnableTitle (MenuHandle menu,
- Boolean enabled);
- static void DoApple (short itemNr);
-
- /*----------*/
- void InitTitles (void)
- {
- %for each menu gen initTitles%
-
- } /*InitTitles*/
-
- /*----------*/
- void LoadMenus (void)
- {
- %for each menu gen get%
-
- %for each menu gen insert%
-
- DrawMenuBar ();
- } /*LoadMenus*/
-
- %for each menu gen doApple%
- /*----------*/
- void DoMenu (long menuChoice)
- {
- short menuID;
- short itemNr;
-
- menuID = HiWord (menuChoice);
- itemNr = LoWord (menuChoice);
-
- switch (menuID) {
- case 0:
- /*Do nothing*/;
- break;
- %for each menu gen dispatch%
-
- } /*switch*/
-
- HiliteMenu (0);
- } /*DoMenu*/
-
- /*----------*/
- MenuHandle menu;
- Boolean menuBarChanged;
-
- /*----------*/
- static void Enable (short itemNr,
- Boolean enabled)
- {
- if (enabled) {
- EnableItem (menu, itemNr);
- } else {
- DisableItem (menu, itemNr);
- }
- } /*Enable*/
-
- /*----------*/
- static void EnableTitle (MenuHandle menu,
- Boolean enabled)
- {
- if (enabled != ((**menu).enableFlags & 1)) {
- menuBarChanged = true;
- }
- if (enabled) {
- EnableItem (menu, 0);
- } else {
- DisableItem (menu, 0);
- }
- } /*EnableTitle*/
-
- /*----------*/
- void UpdateMenus (void)
- {
- WindowPeek frontPeek;
- Boolean isFront; /*is there a front window?*/
- Boolean isCur; /*is there a current window?*/
- Boolean isDirty; /*is it dirty?*/
- Boolean hasFile; /*does it have a file?*/
- Boolean isSelected; /*is anything selected?*/
- Boolean isDesk; /*is the front window a desk acc?*/
- Boolean isText; /*is there a current text field?*/
- Boolean isScrap; /*is there any scrap?*/
- menuBarChanged = false;
-
- isFront = (FrontWindow () != nil);
- isCur = (curWindow != nil);
- isDirty = false;
- hasFile = false;
- isSelected = false;
- if (isCur) {
- isDirty = cur->dirty;
- hasFile = (cur->fileNum != 0);
- }
-
- isDesk = false;
- if (isFront) {
- frontPeek = (WindowPeek) FrontWindow ();
- isDesk = (frontPeek->windowKind < 0);
- }
- isText = isCur && (cur->text != nil);
- isScrap = false;
- if (isText) {
- isSelected = ((**(cur->text)).selStart != (**(cur->text)).selEnd);
- isScrap = (TEGetScrapLen () > 0);
- }
-
- %for each menu gen enable%
-
- if (menuBarChanged) {
- DrawMenuBar ();
- }
- } /*UpdateMenus*/
-
- /* MainMenu */
-